<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8"/>
		<title>工作流</title>
	</head>
	<body>
		<div>
			<span>登录</span>
			<input id="username" placeholder="用户名" /><br />
			<button onclick="login()">提交</button>
		</div>
	</body>
</html>

<style>
* {
	font-family: "微软雅黑";
	font-size: 15px;
	margin: 0 auto;
}
div{
	width: 400px;
	margin-top:100px;
	text-align:center;
	padding-top:10px;
}
input,button{
	margin-top:10px;
}
input{
	width: 400px;
	padding: 5px 3px;
	border: 1px solid #ccc;
	border-radius: 4px;
}

button {
	padding:5px 0;
	width: 408px;
}
</style>

<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"/>
<script>
	function login(){
		$.ajax({
			url : "/login",
			type: "POST",
			data : {
				"username" : $("#username").val()
			},
			success : function(data) {
				console.log(data);
				if(data.code == 200){
					if(data.userType == 1){
						location.href="/home";
					}else{
						location.href="/homeApprover";
					}
				}else{
					alert(data.msg);
				}
			}
		});
	}
</script>